<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateFileGroupTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('file_group', ['comment' => '文件分组', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('name', 'string', ['limit'  =>  60, 'null' => true, 'default' => null, 'comment' => '分组名称'])
            ->addColumn('group', 'string', ['limit'  =>  60, 'default' => '', 'comment' => '分组标识'])
            ->addColumn('weigh', 'integer', ['limit'  =>  8, 'default' => 0, 'comment' => '权重'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addIndex('group', ['unique' => true])
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('file_group');
        $table->drop();
    }
}
